<?php

namespace App\Admin\Actions\Post;

use App\Services\UserService;
use Encore\Admin\Actions\RowAction;
use Illuminate\Database\Eloquent\Model;

class SendVip extends RowAction
{
    public $name = '赠送会员';

    public function handle(Model $model)
    {
        try {
            \DB::beginTransaction();
            UserService::addUserVip($model->id, config('app.vip_day_num'), 5, getOrderNo($model->id, 3));
            \DB::commit();
        }catch (\Exception $exception){
            \DB::rollBack();
            return $this->response()->error($exception->getMessage());
        }
        return $this->response()->success('赠送成功')->refresh();

    }

    public function form() {

    }
}